package com.aaa.utils;

import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.aaa.entity.TSetAncientSingletonAllocation;
import com.aaa.enums.SyncNationReportEnum;
import com.aaa.properties.NationalReportProperty;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Objects;

/**
 * @author : luoBo
 */

@Component
public class SyncUtil {

}/*{

    @Autowired
    private NationalReportProperty nationalReportProperty;

    @Getter
    private static SyncUtil instance;

    private static void requestDate( obj){
        for (SyncNationReportEnum value : SyncNationReportEnum.values()) {
            Class<IService> serviceClazz = value.getServiceClazz();
            IService service = SpringUtil.getBean(serviceClazz);
            QueryWrapper<Object> objectQueryWrapper = new QueryWrapper<>();


            try (HttpResponse response = HttpRequest.post(instance.nationalReportProperty.getIpPort() + value.getSyncNationReportUrl())
                    .header("Content-Type", "application/json")
                    .body(JSONUtil.toJsonStr(JSONUtil.toJsonStr(obj)))
                    .execute()) {
                if (response.getStatus()==200){
                    String body = response.body();
                    JSONObject jsonObject = JSONUtil.parseObj(body);
                    JSONArray result = jsonObject.getJSONArray("result");
                    if (Objects.nonNull(result)){
                        SpringUtil.getBean(value.getServiceClazz());
                    }
                }
            }
        }

    }
}*/
